package br.com.colegio.util;

import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil
{
	public static void main(String[] args)
	{
	}

	public static String getItem(String s, String p)
	{
		Matcher m = Pattern.compile(p, Pattern.CASE_INSENSITIVE).matcher(s);

		if (m.find())
			return m.group(1).trim();

		return null;
	}

	public static Set<String> getItens(String s, String p)
	{
		Matcher     m = Pattern.compile(p, Pattern.CASE_INSENSITIVE).matcher(s);
		Set<String> r = new HashSet<String>();

		while (m.find())
			r.add(m.group(1).trim());

		if (r.size() > 0)
			return r;
		else
			return null;
	}
}
